from selenium import webdriver
from A3mall.Page.Page import Page
from A3mall.Page.Page2 import Page2
from A3mall.Page.Page3 import Page3
from A3mall.Tools.Tools import get_log
import unittest,time
class Case(unittest.TestCase):
    def setUp(self):
        self.driver=webdriver.Edge()
        self.driver.maximize_window()
        self.log=get_log()
        self.log.info('初始化环境')


    def tearDown(self):
        self.driver.quit()
        self.log.info('清理环境')

    def test_a3mall_01_login(self):
        try:
            po=Page(self.driver)
            self.log.info('开始执行用例1')
            po.luoji_a3mall_01_login()
            self.log.info('用例1执行完毕')
        except Exception as e:
            t = time.strftime('%Y%m%d-%H%M%S', time.localtime())
            self.driver.save_screenshot(t + '.png')
            print(e)
            return None

    def test_a3mall_02_search(self):
        try:
            po=Page2(self.driver)
            self.log.info('开始执行用例2')
            po.luoji_a3mall_02_search()
            self.log.info('用例2执行完毕')
        except Exception as e:
            t = time.strftime('%Y%m%d-%H%M%S', time.localtime())
            self.driver.save_screenshot(t + '.png')
            print(e)
            return None
    def test_a3mall_03_car(self):
        try:
            po=Page3(self.driver)
            self.log.info('开始执行用例3')
            po.luoji_a3mall_03_car()
            self.log.info('用例3执行完毕')
        except Exception as e:
            t = time.strftime('%Y%m%d-%H%M%S', time.localtime())
            self.driver.save_screenshot(t + '.png')
            print(e)
            return None


if __name__ == '__main__':
    unittest.main()
